package com.fowo.api.costAccounting.mapper;

import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.fowo.api.costAccounting.model.bd.BdAccperiodmonthVo;
import com.fowo.api.costAccounting.model.monthly.MonthlyVo;
import com.fowo.api.costAccounting.model.stock.StockInMonthlyVo;
import com.fowo.api.costAccounting.model.stock.StockOutMonthlyVo;
import com.fowo.api.costAccounting.model.stock.StockVo;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import java.math.BigDecimal;
import java.util.Date;
import java.util.List;
import java.util.Map;

@Mapper
public interface CommonCostingMapper extends BaseMapper {

    /**
     *  成本结算统一放入  需要有这些表 不然用不了
     *
     */

     //修改销售出库单
    void updateSalesOutboundByType(@Param("item") MonthlyVo monthlyVo);
    //修改出库单
    void updateStockOutByType(@Param("item") MonthlyVo monthlyVo);
    //查询入库单数据
    StockInMonthlyVo getByMonthlyCostReport(@Param("orgId")Long orgId, @Param("itemId")Long itemId,
                                            @Param("shopId")String shopId,@Param("stockId") Long stockId,
                                            @Param("type")String type,@Param("beginDate")Date beginDate,@Param("endDate")Date endDate);

    void updateStockOutByTypeBatch(List<MonthlyVo> monthlyVoList);

    void updateSalesOutboundByTypeBatch(List<MonthlyVo> monthlyVoList);

    BigDecimal getSKUPrice(@Param("itemId")Long itemId);

    List<BdAccperiodmonthVo> getByStatus();
    @Select("${sql}")
    StockInMonthlyVo selectSql(String sql);

    @Select("${sql}")
    List<StockVo> selectSqlByCarrForward(String sql);
    //修改sql
    @Update("${sql}")
    void updateSql(String sql);

    List<BdAccperiodmonthVo> getByAccperiodMonth(@Param("accperiodMonth") String lastMonth);

    //查询出库单数据
    StockOutMonthlyVo getByMonthlyCostReportByOut(@Param("orgId")Long orgId, @Param("itemId")Long itemId,
                                                  @Param("shopId")String shopId,@Param("stockId") Long stockId,
                                                  @Param("type")String type,@Param("beginDate")Date beginDate,@Param("endDate")Date endDate);

    //查询入库单数据
    List<StockInMonthlyVo> getNotReportStockIn(@Param("periodId")Long periodId,@Param("beginDate")Date beginDate,@Param("endDate")Date endDate);

    List<StockInMonthlyVo> getNotInventoryMonthlyStockIn(@Param("periodId")Long periodId,@Param("beginDate")Date beginDate,@Param("endDate")Date endDate);


    List<StockInMonthlyVo> getByMonthlyCostReportList(@Param("type")String type,@Param("beginDate")Date beginDate,@Param("endDate")Date endDate);

    List<StockInMonthlyVo> getStockInList(@Param("type")String type,@Param("beginDate")Date beginDate,@Param("endDate")Date endDate);

    List<StockOutMonthlyVo> getStockOutList(@Param("type")String type,@Param("beginDate")Date beginDate,@Param("endDate")Date endDate);

    List<Map> getSKUPriceList();
    @Select("${sql}")
    List<StockInMonthlyVo> selectStockInSql(String sql);
    @Select("${sql}")
    List<StockOutMonthlyVo> selectSqlByCarrForwardOut(String sql);
    @Select("${sql}")
    List<Map> selectSqlMap(String sql);
    //修改sql
    void updateSqlList(List<String> list);

    void updateMonthlyCostReportBatch(List<MonthlyVo> list);

    @Select("${sql}")
    List<Map<String,Object>> selectSqlMaps(String sql);

    @Select("${sql}")
    List<JSONObject> selectSqlJson(String sql);
}
